package com.ruoyi.performance.service.impl;

import java.util.List;

import com.ruoyi.performance.domain.SysPerformanceType;
import com.ruoyi.performance.mapper.SysPerformanceTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import com.ruoyi.performance.mapper.SysPerformanceTemplateMapper;
import com.ruoyi.performance.domain.SysPerformanceTemplate;
import com.ruoyi.performance.service.ISysPerformanceTemplateService;

/**
 * 绩效模版Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-03-23
 */
@Service
public class SysPerformanceTemplateServiceImpl implements ISysPerformanceTemplateService 
{
    @Autowired
    private SysPerformanceTemplateMapper sysPerformanceTemplateMapper;
    @Autowired
    private SysPerformanceTypeMapper sysPerformanceTypeMapper;
    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * 查询绩效模版
     * 
     * @param id 绩效模版主键
     * @return 绩效模版
     */
    @Override
    public SysPerformanceTemplate selectSysPerformanceTemplateById(Long id)
    {
        return sysPerformanceTemplateMapper.selectSysPerformanceTemplateById(id);
    }

    /**
     * 查询绩效模版列表
     * 
     * @param sysPerformanceTemplate 绩效模版
     * @return 绩效模版
     */
    @Override
    public List<SysPerformanceTemplate> selectSysPerformanceTemplateList(SysPerformanceTemplate sysPerformanceTemplate)
    {
        List<SysPerformanceTemplate> sysPerformanceTemplates = sysPerformanceTemplateMapper.selectSysPerformanceTemplateList(sysPerformanceTemplate);
        Object o = redisTemplate.opsForValue().get("performance-template");
        if(o==null){
            redisTemplate.opsForValue().set("performance-template",sysPerformanceTemplates);
        }

        return sysPerformanceTemplates;
    }

    /**
     * 新增绩效模版
     * 
     * @param sysPerformanceTemplate 绩效模版
     * @return 结果
     */
    @Override
    public int insertSysPerformanceTemplate(SysPerformanceTemplate sysPerformanceTemplate)
    {
        return sysPerformanceTemplateMapper.insertSysPerformanceTemplate(sysPerformanceTemplate);
    }

    /**
     * 修改绩效模版
     * 
     * @param sysPerformanceTemplate 绩效模版
     * @return 结果
     */
    @Override
    public int updateSysPerformanceTemplate(SysPerformanceTemplate sysPerformanceTemplate)
    {
        return sysPerformanceTemplateMapper.updateSysPerformanceTemplate(sysPerformanceTemplate);
    }

    /**
     * 批量删除绩效模版
     * 
     * @param ids 需要删除的绩效模版主键
     * @return 结果
     */
    @Override
    public int deleteSysPerformanceTemplateByIds(Long[] ids)
    {
        return sysPerformanceTemplateMapper.deleteSysPerformanceTemplateByIds(ids);
    }

    /**
     * 删除绩效模版信息
     * 
     * @param id 绩效模版主键
     * @return 结果
     */
    @Override
    public int deleteSysPerformanceTemplateById(Long id)
    {
        return sysPerformanceTemplateMapper.deleteSysPerformanceTemplateById(id);
    }
}
